﻿@using ClassifiedAds.IdentityServer.Models.ClientModels
@model PropertiesModel

<form asp-controller="Client" asp-action="AddProperty" Method="post">
    <div class="row">

        <div class="col-12">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a asp-controller="Client" asp-action="Index">Clients</a></li>
                    <li class="breadcrumb-item"><a asp-controller="Client" asp-action="Edit" asp-route-id="@Model.Client.Id">@Model.Client.ClientId</a></li>
                    <li class="breadcrumb-item active" aria-current="page">Properties</li>
                </ol>
            </nav>
        </div>

        <div class="col-md-12">

            <h3>Properties</h3>

            <div asp-validation-summary="All" class="text-danger"></div>

            <!--Hidden -->
            <input type="hidden" asp-for="Client.Id" />

            <div class="card mt-3">
                <h5 class="card-header">Add Property</h5>
                <div class="card-body">

                    <!--Input - text -->
                    <div class="form-group row">
                        <label asp-for="Key" class="col-sm-3 col-form-label">
                            @await Html.PartialAsync("_Label", "Property Key")
                        </label>
                        <div class="col-sm-9">
                            <input type="text" required class="form-control" asp-for="Key">
                            <span asp-validation-for="Key" class="text-danger"></span>
                        </div>
                    </div>

                    <!--Input - text -->
                    <div class="form-group row">
                        <label asp-for="Value" class="col-sm-3 col-form-label">
                            @await Html.PartialAsync("_Label", "Property Value")
                        </label>
                        <div class="col-sm-9">
                            <input type="text" required class="form-control" asp-for="Value">
                            <span asp-validation-for="Value" class="text-danger"></span>
                        </div>
                    </div>

                    <!--Button-->
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">
                        </label>
                        <div class="col-sm-9">
                            <button type="submit" class="btn btn-primary">Add Property</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

<div class="row">
    <div class="col-md-12">
        <div class="card mt-3">
            <h5 class="card-header">Properties</h5>
            <div class="card-body">
                <div class="row table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>Key</th>
                                <th>Value</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var ApiResourceProperty in Model.Properties)
                            {
                                <tr>
                                    <td>@ApiResourceProperty.Key</td>
                                    <td>@ApiResourceProperty.Value</td>
                                    <td><a asp-action="DeleteProperty" asp-route-id="@ApiResourceProperty.Id" class="btn btn-danger">Remove</a></td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>

                <div class="row">
                    <div class="col-12">
                        @*@await Html.PartialAsync("Common/Pager", new Pager { Action = "ApiResourceProperties", PageSize = Model.PageSize, TotalCount = Model.TotalCount })*@
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>